package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import metier.Objet;

public class CharacterParameters implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7049862228239572670L;
	protected ObjectRepresentation initialRepresentation;
	protected Position initialPosition;
	protected Dimension movementBordersDimension;
	protected SpriteSequence movementSpriteSequence;
	protected Sound moveSound;
	protected List<Behaviour> behaviours = new ArrayList<Behaviour>();
	
	public Objet generateObject() {
		if(initialPosition.row != null && initialPosition.column!=null)
			return new Objet(new Position(initialPosition.row, initialPosition.column),initialRepresentation);
		if(initialPosition.row == null && initialPosition.column!=null) {
			Dimension borders = movementBordersDimension;
			int minRow = borders.getRow();
			int height = borders.getHeight();
			int rnd = minRow + new Random().nextInt(height);
			return new Objet(new Position(rnd, initialPosition.column),initialRepresentation);
		}
		if(initialPosition.row != null && initialPosition.column==null) {
			Dimension borders = movementBordersDimension;
			int minCol = borders.getColumn();
			int width = borders.getWidth();
			int rnd = minCol + new Random().nextInt(width);
			return new Objet(new Position(initialPosition.row, rnd),initialRepresentation);
		}
		
		Dimension borders = movementBordersDimension;
		int minCol = borders.getColumn();
		int width = borders.getWidth();
		int rndCol = minCol + new Random().nextInt(width);
		int minRow = borders.getRow();
		int height = borders.getHeight();
		int rndRow = minRow + new Random().nextInt(height);
		return new Objet(new Position(rndRow, rndCol),initialRepresentation);
	}

	public List<Behaviour> getBehaviours() {
		return behaviours;
	}
	public void setBehaviours(List<Behaviour> behaviours) {
		this.behaviours = behaviours;
	}
	public ObjectRepresentation getInitialRepresentation() {
		return initialRepresentation;
	}
	public void setInitialRepresentation(ObjectRepresentation initialRepresentation) {
		this.initialRepresentation = initialRepresentation;
	}
	public Sound getMoveSound() {
		return moveSound;
	}
	public void setMoveSound(Sound moveSound) {
		this.moveSound = moveSound;
	}
	public Position getInitialPosition() {
		return initialPosition;
	}
	public void setInitialPosition(Position initialPosition) {
		this.initialPosition = initialPosition;
	}
	public Dimension getMovementBordersDimension() {
		return movementBordersDimension;
	}
	public void setMovementBordersDimension(Dimension movementBordersDimension) {
		this.movementBordersDimension = movementBordersDimension;
	}
	public SpriteSequence getMovementSpriteSequence() {
		return movementSpriteSequence;
	}
	public void setMovementSpriteSequence(SpriteSequence movementSpriteSequence) {
		this.movementSpriteSequence = movementSpriteSequence;
	}
	
	
}
